<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="client_contact" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="contactsAddSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="contactsAddSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存并新建</el-button>
      <el-button @click="gotoPage('/crm/sale/contacts/ContactsChoiceList?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>取消</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 添加联系人 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="分公司" prop="client_downfirm">
              <el-input v-model="client_contact.client_downfirm" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-radio-group v-model="client_contact.client_oneorclient">
              <el-radio-button label="个人联系人">个人联系人</el-radio-button>
              <el-radio-button label="客户联系人">客户联系人</el-radio-button>
            </el-radio-group>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="相关的记录" prop="">
              <el-link @click="gotoPage(''+vueparams+'')" type='primary'></el-link>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="联系人类别" prop="client_contacttype">
              <el-select style='width:100%' v-model="client_contact.client_contacttype">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in clienttype" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="联系人类型" prop="client_contactmode">
              <el-select style='width:100%' v-model="client_contact.client_contactmode">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in clientsort" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-input v-model="client_contact.client_visittype" />
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="英文名" prop="client_contactengname">
              <el-input v-model="client_contact.client_contactengname" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="姓名" prop="client_contactname">
              <el-input v-model="client_contact.client_contactname" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="性别" prop="client_contactsex">
              <el-radio-group v-model="client_contact.client_contactsex">
                <el-radio-button label="男">男</el-radio-button>
                <el-radio-button label="女">女</el-radio-button>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="附加名称" prop="client_annexname">
              <el-input v-model="client_contact.client_annexname" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="昵称" prop="client_nickname">
              <el-input v-model="client_contact.client_nickname" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="出生日期" prop="client_birthday">
              <el-date-picker v-model="client_contact.client_birthday" type="date" style='width:100%' value-format="yyyy-MM-dd" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="公司" prop="client_firm">
              <el-input v-model="client_contact.client_firm" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="岗位" prop="client_contactpost">
              <el-select style='width:100%' v-model="client_contact.client_contactpost">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in station_info" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="角色" prop="client_contactrole">
              <el-input v-model="client_contact.client_contactrole" />
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 电话号码 </span>
      </div>
      <el-table>
        <el-table-column label="电话" prop="">
        </el-table-column>
        <el-table-column label="类型" prop="">
          <template slot-scope="scope">
            <el-select style='width:100%' v-model="empty">
              <el-option label="商业电话" value="商业电话" />
              <el-option label="商业传真" value="商业传真" />
              <el-option label="移动电话" value="移动电话" />
            </el-select>
          </template>
        </el-table-column>
        <el-table-column label="号码" prop="">
          <template slot-scope="scope">
            <el-input v-model="empty" />
          </template>
        </el-table-column>
        <el-table-column label="分机" prop="">
          <template slot-scope="scope">
            <el-input v-model="empty" />
          </template>
        </el-table-column>
        <el-table-column label="主要的" prop="">
          <template slot-scope="scope">
            <el-radio-group v-model="empty">
              <el-radio-button label=""></el-radio-button>
            </el-radio-group>
          </template>
        </el-table-column>
        <el-table-column label="电话号码谢绝" prop="">
          <template slot-scope="scope">
            <el-checkbox v-model="empty" :checked="empty==1? true:false" label="谢绝来电">谢绝来电</el-checkbox>
            <el-checkbox v-model="empty" :checked="empty==1? true:false" label="谢绝传真">谢绝传真</el-checkbox>
          </template>
        </el-table-column>
      </el-table>
      <div class="form-unit">
        <span class="mvc-title-left"> 电子邮件地址 </span>
      </div>
      <el-table>
        <el-table-column label="电话" prop="">
        </el-table-column>
        <el-table-column label="类型" prop="">
          <template slot-scope="scope">
            <el-select style='width:100%' v-model="empty">
              <el-option label="商业" value="商业" />
              <el-option label="个人" value="个人" />
              <el-option label="其他" value="其他" />
            </el-select>
          </template>
        </el-table-column>
        <el-table-column label="号码" prop="">
          <template slot-scope="scope">
            <el-input v-model="empty" />
          </template>
        </el-table-column>
        <el-table-column label="主要的" prop="">
          <template slot-scope="scope">
            <el-radio-group v-model="empty">
              <el-radio-button label=""></el-radio-button>
            </el-radio-group>
          </template>
        </el-table-column>
        <el-table-column label="邮件谢绝" prop="">
          <template slot-scope="scope">
            <el-radio-group v-model="empty">
              <el-radio-button label="是">是</el-radio-button>
              <el-radio-button label="否">否</el-radio-button>
            </el-radio-group>
          </template>
        </el-table-column>
      </el-table>
      <div class="form-unit">
        <span class="mvc-title-left"> 即时通讯地址 </span>
      </div>
      <el-table>
        <el-table-column label="即时通讯地址" prop="">
        </el-table-column>
        <el-table-column label="类型" prop="">
          <template slot-scope="scope">
            <el-select style='width:100%' v-model="empty">
              <el-option label="商业" value="商业" />
              <el-option label="个人" value="个人" />
              <el-option label="其他" value="其他" />
            </el-select>
          </template>
        </el-table-column>
        <el-table-column label="类型2" prop="">
          <template slot-scope="scope">
            <el-select style='width:100%' v-model="empty">
              <el-option label="ICQ" value="ICQ" />
              <el-option label="OICQ" value="OICQ" />
              <el-option label="MSN" value="MSN" />
            </el-select>
          </template>
        </el-table-column>
        <el-table-column label="号码" prop="">
          <template slot-scope="scope">
            <el-input v-model="empty" />
          </template>
        </el-table-column>
        <el-table-column label="主要的" prop="">
          <template slot-scope="scope">
            <el-radio-group v-model="empty">
              <el-radio-button label=""></el-radio-button>
            </el-radio-group>
          </template>
        </el-table-column>
        <el-table-column label="有无IM请求" prop="">
          <template slot-scope="scope">
            <el-radio-group v-model="empty">
              <el-radio-button label="有">有</el-radio-button>
              <el-radio-button label="无">无</el-radio-button>
            </el-radio-group>
          </template>
        </el-table-column>
      </el-table>
      <div class="form-unit">
        <span class="mvc-title-left"> 文本消息地址 </span>
      </div>
      <el-table>
        <el-table-column label="地址" prop="">
        </el-table-column>
        <el-table-column label="类型" prop="">
          <template slot-scope="scope">
            <el-select style='width:100%' v-model="empty">
              <el-option label="QQ" value="QQ" />
              <el-option label="MSN" value="MSN" />
              <el-option label="商业" value="商业" />
            </el-select>
          </template>
        </el-table-column>
        <el-table-column label="地址栏" prop="">
          <template slot-scope="scope">
            <el-input v-model="empty" />
          </template>
        </el-table-column>
        <el-table-column label="主要的" prop="">
          <template slot-scope="scope">
            <el-radio-group v-model="empty">
              <el-radio-button label=""></el-radio-button>
            </el-radio-group>
          </template>
        </el-table-column>
        <el-table-column label="" prop="">
          <template slot-scope="scope">
            <el-radio-group v-model="empty">
              <el-radio-button label="是">是</el-radio-button>
              <el-radio-button label="否">否</el-radio-button>
            </el-radio-group>
          </template>
        </el-table-column>
      </el-table>
      <div class="form-unit">
        <span class="mvc-title-left"> 地址 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="类型" prop="">
              <el-select style='width:100%' v-model="empty">
                <el-option label="主要的" value="主要的" />
                <el-option label="辅助的" value="辅助的" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="地址行1" prop="">
              <el-input v-model="empty" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="地址行2" prop="">
              <el-input v-model="empty" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="地址行3" prop="">
              <el-input v-model="empty" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="地址行4" prop="">
              <el-input v-model="empty" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="城市" prop="">
              <el-input v-model="empty" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="省" prop="">
              <el-select style='width:100%' v-model="empty">
                <el-option label="--无--" value="--无--" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="邮政编码" prop="">
              <el-input v-model="empty" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-select style='width:100%' v-model="empty">
              <el-option label="国家" value="国家" />
            </el-select>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="纬度" prop="">
              <el-input v-model="empty" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="经度" prop="">
              <el-input v-model="empty" />
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 额外明细 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="client_remark">
              <el-input type="textarea" v-model="client_contact.client_remark" ttparea=350></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="gotoPage(''+vueparams+'')" type='primary' size="mini">保存</el-button>
      <el-button @click="gotoPage('/crm/sale/contacts/ContactsAdd?'+vueparams+'')" type='primary' size="mini">保存并新建</el-button>
      <el-button @click="gotoPage('/crm/sale/contacts/ContactsChoiceList?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>取消</el-button>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'ContactsAdd',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        client_contact: {
          client_downfirm: null,
          client_oneorclient: null,
          client_contacttype: null,
          client_contactmode: null,
          client_visittype: null,
          client_contactengname: null,
          client_contactname: null,
          client_contactsex: null,
          client_annexname: null,
          client_nickname: null,
          client_birthday: null,
          client_firm: null,
          client_contactpost: null,
          client_contactrole: null,
          client_remark: null,
        },
        clienttype: [],
        clientsort: [],
        station_info: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/contacts/ContactsAdd/contactsAdd?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      contactsAddSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/crm/sale/contacts/ContactsAdd/contactsAddSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/crm/sale/contacts/VUE4AE458773C224D86B75089A58894ED3E?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
    },
  }
</script>
